﻿using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Text;
using WeChat.PlatForm.Entity;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace WeChat.PlatForm.DataAccess.Configs
{
    public class UserRoleConfig : IEntityTypeConfiguration<UserRoleEntity>
    {
        public void Configure(EntityTypeBuilder<UserRoleEntity> builder)
        {
            //指定数据库中的表
            builder.ToTable("T_USER_ROLE");


            //一对多关系，关联外键  模拟多对多
            builder.HasOne(a => a.User).WithMany().HasForeignKey(a => a.USER_ID);
            builder.HasOne(a => a.Role).WithMany().HasForeignKey(a => a.ROLE_ID);
        }
    }
}
